package com.nanrui.mutualinductor.ui.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nanrui.mutualinductor.R;

import java.util.List;


public class RechargePhoneAdapter extends BaseAdapter {

    public List<String> mList;

    private Context mContext;

    public RechargePhoneAdapter(Context context, List<String> list) {

        mContext = context;
        mList = list;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public String getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder mViewHolder;
        if (null == convertView) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_grid, parent, false);
            mViewHolder = new MyViewHolder();
            mViewHolder.mTextView = convertView.findViewById(R.id.tv_name);
            convertView.setTag(mViewHolder);
        } else {
            mViewHolder = (MyViewHolder) convertView.getTag();
        }

        String entity = mList.get(position);
        mViewHolder.mTextView.setText(entity);
        return convertView;
    }

    public class MyViewHolder {
        TextView mTextView;
    }
}
